package com.stars.empoly.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.stars.empoly.adapter.IncomeListAdapter
import com.stars.empoly.base.MBRFragment
import com.stars.empoly.databinding.FragmentIncomeListBinding
import com.stars.empoly.model.DriverProfit
import com.stars.empoly.vmodel.IncomeListVModel
import com.trailer.base.net.IResp

/**
 *on 2021/5/9
 */
class IncomeListFragment : MBRFragment<IncomeListVModel, IncomeListAdapter, FragmentIncomeListBinding>(){

    override fun __before(savedInstanceState: Bundle?) {
        super.__before(savedInstanceState)
        vm.type=arguments?.getString("type")
        vm.status=arguments?.getString("status")

    }

    override fun vmClass(): Class<IncomeListVModel> {
        return IncomeListVModel::class.java
    }

    override fun binding(inflater: LayoutInflater, container: ViewGroup?): FragmentIncomeListBinding {
       return FragmentIncomeListBinding.inflate(layoutInflater)
    }

    override fun initAdapter(): IncomeListAdapter {
        return IncomeListAdapter(vm)
    }

    override fun onListReceive(res: IResp<*>) {
        super.onListReceive(res)

        if (null != res) {

            var list = res.data() as List<DriverProfit>
            if (list.isEmpty() && vm.repository().page == 1) {

                binding.listEmpty.visibility = View.VISIBLE
            } else {
                binding.listEmpty.visibility = View.GONE
            }

        }
    }

    override fun title(): String? {
        return null
    }
}
